package model.dao;

import java.util.ArrayList;
import model.dao.ulti.HibernateUtil;
import model.pojo.ChiTietGioHang;
import model.pojo.ChiTietGioHangId;
import org.hibernate.Query;
import org.hibernate.Session;

public class ChiTietGioHangDAO extends AbstractDAO<ChiTietGioHang, ChiTietGioHangId> {

    @Override
    protected Class getPOJOClass() {
        return ChiTietGioHang.class;
    }
        public static ArrayList<ChiTietGioHang> timKiem(String maGioHang) {

        ArrayList<ChiTietGioHang> ds = null;
        Session session = HibernateUtil.getSessionFactory().openSession();
        String hql = "from ChiTietGioHang s where s.gioHang.maGioHang=:ma_gio_hang";
        Query query = session.createQuery(hql);
        query.setString("ma_gio_hang", maGioHang);

        ds = (ArrayList<ChiTietGioHang>) query.list();
        session.close();
        return ds;
    }
        
}
